﻿using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

namespace UIOC.CodeAnalysis.Extensions;

internal static class AccessibilityExtensions {

    /// <summary>
    /// 将Accessibility转换为对应的SyntaxKind（访问修饰符关键字）
    /// </summary>
    public static SyntaxKind? ToSyntaxKind(this Accessibility accessibility) {
        return accessibility switch {
            Accessibility.Public => SyntaxKind.PublicKeyword,
            Accessibility.Private => SyntaxKind.PrivateKeyword,
            Accessibility.Protected => SyntaxKind.ProtectedKeyword,
            Accessibility.Internal => SyntaxKind.InternalKeyword,
            Accessibility.ProtectedOrInternal => SyntaxKind.ProtectedKeyword, // 对应 "protected internal"
            Accessibility.ProtectedAndInternal => SyntaxKind.PrivateKeyword,  // 对应 "private protected"
            _ => null // 未知或无访问修饰符（如默认的internal）
        };
    }
}
